﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    /// <summary>
    /// 封装类BD
    /// </summary>
   public class DB
    {
        /// <summary>
        ///获取 数据库字符串
        /// </summary>
       static string ss = ConfigurationManager.AppSettings["wwj"];
        /// <summary>
        /// 封装查询
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataTable GetTable(string sql) {
            SqlDataAdapter dat = new SqlDataAdapter(sql,ss);
            DataTable da = new DataTable();
            dat.Fill(da);
            return da;
        }
        /// <summary>
        /// 封装增删改
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static bool ZSG(string sql) {
            SqlConnection conn = new SqlConnection(ss);
            SqlCommand com = new SqlCommand(sql,conn);
            conn.Open();
            int result = com.ExecuteNonQuery();
            conn.Close();
            return result > 0;
        }
    }
}
